package com.ben.xinyue.seckill.controller;

import com.ben.basic.exception.BaseResponse;
import com.ben.basic.exception.DefaultSuccessEnum;
import com.ben.xinyue.seckill.domain.vo.LoginVo;
import com.ben.xinyue.seckill.service.MiaoshaUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @ClassName: LoginController
 * @Description: 登陆
 * @author: xinyue
 * @date: 2020/9/2 9:17 下午
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/login")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LoginController {

    private final MiaoshaUserService miaoshaUserService;

    @PostMapping("login")
    public BaseResponse<Boolean> login(@Valid LoginVo loginVo, HttpServletResponse response){

        System.out.println(loginVo.getPassword());
        miaoshaUserService.login(response, loginVo);
        return BaseResponse.business(DefaultSuccessEnum.LOGIN_SUCCESS);
    }
}
